﻿using System;
using System.Collections.Generic;
using Generator.Selections.DataBase;

namespace Generator.Selections.Repository
{
    class OwnerRepository
    {
        internal List<string> GetUserNames()
        {
            var result = new List<string>();

            try
            {
                ConnectionHandler.Instance.Connection.Open();
                using (var cmd = DataDictionaryCommands.GetSelectUsersCommand())
                {
                    using (var rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            result.Add(rdr[0].ToString());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
            finally
            {
                ConnectionHandler.Instance.Connection.Close();
            }

            return result;
        }
    }
}
